package com.example.controller;


import com.example.annotation.JwtIgnore;
import com.example.common.Result;
import com.example.service.MovieService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "影视资源相关")
@RestController
@CrossOrigin(origins = "*", methods = {RequestMethod.GET, RequestMethod.PUT})
@Slf4j
//@RequestMapping("/movie")
public class MovieController {
    @Autowired
    MovieService movieService;

    @ApiOperation("获取影视")
    @GetMapping("/items")
    @JwtIgnore
    public Result list(@RequestParam(value = "start", defaultValue = "1") int start,
                       @RequestParam(value = "size", defaultValue = "10") int size,
                       @RequestParam(value = "genre", defaultValue = "") String genre) {
        return movieService.listMovies(start, size, genre);

    }

    @ApiOperation("获取所有类别")
    @GetMapping("/genres")
    @JwtIgnore
    public Result getGenres(@RequestParam(value = "big_genre", defaultValue = "") String big_genre) {
        return movieService.listGenres(big_genre);
    }

    @ApiOperation("获取播放地址")
    @GetMapping(value = "/resource")
    public Result resource(@RequestParam(value = "id", defaultValue = "无") String id,
                           @RequestParam(value = "resource", defaultValue = "1") String resource) {
        return movieService.listResources(resource, id);
    }

}

